<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
   <el-form-item label="宿舍号" prop="locationName">
     <el-input
       v-model="queryParams.locationName"
       placeholder="请输入宿舍号"
       clearable
       size="small"
       style="width: 240px"
       @keyup.enter.native="handleQuery"
     />
   </el-form-item>
  
   <el-form-item label="考勤时间" >
          <el-date-picker clearable
            v-model="queryParams.createTime"
            type="date"
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
  
   <el-form-item>
     <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
     <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
   </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="dormitoryList">
        <el-table-column label="序号" align="center" prop="id" />
        <el-table-column label="宿舍栋号" align="center" prop="levelName"  />
        <!-- <el-table-column label="楼层" align="center" prop="level" /> -->
        <el-table-column label="宿舍号" align="center" prop="locationName" :show-overflow-tooltip="true" />
        <el-table-column label="实住人数" align="center" prop="dormitoryCount" :show-overflow-tooltip="true" />
        <el-table-column label="出勤日期" align="center" prop="createTime" :show-overflow-tooltip="true" >
            <template>
            <span>{{ parseTime(this.queryParams.createTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="出勤比率" align="center" prop="attendanceRatio" :show-overflow-tooltip="true" />
        <el-table-column label="请假比率" align="center" prop="leaveRatio" :show-overflow-tooltip="true" />
      </el-table>
  
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>  
  </template>

<script>
import { getDormitoryStatistics} from "@/api/attendance/statistics"

export default {
  name: "dormitoryStatistics",
  data() {
    return {
        loading:false,
        dormitoryList:[],
        dateTime: undefined,
         // 总条数
        total: 0,
        queryParams: {
            pageNum: 1,
            pageSize: 10,
            createTime: new Date()
        }
    };
   },
  created() {
    this.getList();
   },
    methods: {
            /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.queryParams.createTime = new Date();
      this.resetForm("queryForm");
      this.handleQuery();
    },
    getList() {
            this.loading = true
            getDormitoryStatistics(this.queryParams).then(response => {
            this.dormitoryList = response.data.list;
            this.total = response.data.total;
            this.loading = false;
        });
    },

    }
};
</script>  